package com.example.hnvehicle.controller;

import com.example.hnvehicle.bean.RepairPoint;
import com.example.hnvehicle.service.RepairPointService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Shunrai
 * @Date 2023/5/25 11:21
 * @Version 1.0
 * @Description
 */
@RestController
@RequestMapping("/repairPoint")
public class RepairPointController {
    @Resource
    RepairPointService repairPointService;

    @RequestMapping("/delete")
    public String deleteRepairPoint(String rpId){
        boolean b = repairPointService.removeById(Integer.parseInt(rpId));
        return b?"删除成功":"删除失败";
    }

    @RequestMapping("/getAll")
    public List<RepairPoint> getAll(){
        return repairPointService.list();
    }

    @RequestMapping("/add")
    public String addRepairPoint(String title,String lng,String lat){
        RepairPoint repairPoint = new RepairPoint();
        repairPoint.setTitle(title);
        repairPoint.setLng(Double.parseDouble(lng));
        repairPoint.setLat(Double.parseDouble(lat));
        boolean save = repairPointService.save(repairPoint);
        return save?"添加成功":"添加失败";
    }
}
